<template>
	<view class="content">
		<view class="content-item">
			<view class="content-item-left">
				<view class="content-item-left-title">
					累计维保次数
				</view>
				<view class="content-item-left-dec">
					{{total}} 次
				</view>
			</view>
			<u-image src="@/static/home/daiweibao.png" width="92rpx" height="95rpx"></u-image>
		</view>
		<u-empty v-if="historyList.length == 0" mode="list" style="margin-top: 300rpx;"></u-empty>
		<view class="history-item" v-for="(item, index) in historyList" :key="index">
			<view class="history-item-index">
				{{index + 1}}
			</view>
			<view class="history-item-left">
				<view class="history-item-time">
					{{item.maintenanceTime}}
				</view>
				<view class="history-item-text">
					<view class="history-item-text-azr">
						维保人：{{item.maintenancePersonStr}}
					</view>
				</view>
			</view>
			<view class="history-item-right" @click="toDetail(item)">
				查看详情
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				historyList: [],
				total: 0,
				queryForm: {
					state: [2],
					equipmentId: '',
					pageNum: 1,
					pageSize: 20
				}
			}
		},
		onLoad(option) {
			this.queryForm.equipmentId = option.equipmentId
			this.getPage()
		},
		onReachBottom() {
			if (this.total > this.queryForm.pageSize * this.queryForm.pageNum) {
				this.queryForm.pageNum++
				this.getPage()
			}
		},
		onPullDownRefresh() {
			this.historyList = []
			this.queryForm.pageNum = 1
			this.getPage()
			uni.stopPullDownRefresh()
		},
		methods: {
			getPage() {
				this.$u.api.maintenanceQuery(this.queryForm).then(res => {
					this.historyList = this.historyList.concat(res.rows)
					this.total = res.recordCount
				})
			},
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/repair/detail?id=' + item.id
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #F5F7FA;
	}
</style>
<style lang="scss" scoped>
	.content {
		padding: 32rpx 28rpx;

		.content-item {
			background: url('@/static/home/item.png');
			width: 100%;
			height: 200rpx;
			background-size: cover;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 47rpx 56rpx 50rpx 61rpx;
			margin-bottom: 28rpx;

			.content-item-left {
				.content-item-left-title {
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;
				}

				.content-item-left-dec {
					font-weight: 600;
					font-size: 48rpx;
					color: #333333;
					line-height: 64rpx;
				}
			}
		}
		.history-item {
			position: relative;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 58rpx 32rpx 41rpx 46rpx;
			width: 694rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-bottom: 30rpx;
			
				
			.history-item-index {
				position: absolute;
				left: 0;
				top: 0;
				line-height: 48rpx;
				background: #3068E7;
				border-radius: 16rpx 0rpx 16rpx 0rpx;
				text-align: center;
				font-weight: 600;
				font-size: 28rpx;
				color: #FFFFFF;
				padding: 0 22rpx;
			}
			.history-item-left {
				.history-item-time {
					font-weight: 600;
					font-size: 36rpx;
					color: #333333;
					line-height: 50rpx;
				}
				.history-item-text {
					font-weight: 400;
					font-size: 26rpx;
					color: #999999;
					line-height: 37rpx;
					display: flex;
					.history-item-text-azr {
						padding-right: 21rpx;
						border-right: 1rpx solid #E6E6E6;
					}
					.history-item-text-azgs {
						padding-left: 21rpx;
					}
				}
			}
			.history-item-right {
				width: 150rpx;
				line-height: 54rpx;
				background: #3068E7;
				border-radius: 30rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #FFFFFF;
				text-align: center;
			}
		}

	}
</style>